package com.kuang.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@Controller
public class RestFulController {

    //http://localhost:8080/add?a=1&b=1
    //http://localhost:8080/add/a/b

//    @RequestMapping("/add")
//    public String test1(int a, int b, Model model){
//        int res= a+b;
//        model.addAttribute("msg","结果为"+res);
//
//        return "test";
//    }



   @PostMapping("/add/{a}/{b}")
    public String test1(@PathVariable int a, @PathVariable  int b, Model model){
        int res= a+b;
        model.addAttribute("msg","结果1为"+res);

        return "test";
    }

    @RequestMapping(value = "/add/{a}/{b}" , method = RequestMethod.GET)//限定提交方法
    public String test2(@PathVariable String a, @PathVariable  String  b, Model model){
        String res= a+b;
        model.addAttribute("msg","结果2为"+res);

        return "test";
    }
}
